<?php header("Content-type: text/html; charset=utf-8")?>
<?php
require "redis.php";
$username="";
$pass="";
if(isset($_POST["username"]))
{
    $username=$_POST["username"];
}
if(isset($_POST["password"])){
    $pass=$_POST["password"];
}
$id=$redis->get("username:".$username);
if(!empty($id)){
    $password=$redis->hGet("user:$id","password");
    if(md5($pass)==$password){
        echo 'en';
        $auth=md5(time().$username.rand());
        $redis->set("auth:".$auth,$id);
        setcookie("auth",$auth,time()+86400);
        header("location:list.php");
    }
}
?>
<form action="" method="post">
    用户名:<input type="text" name="username"><br>
    密码:<input type="password" name="password"><br>
    <input type="submit" value="登陆"> <input type="reset" value="重新填写"><br>
</form>